using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace BookingDB.Models.Mapping
{
    public class ShowMap : EntityTypeConfiguration<EntityShow>
    {
        public ShowMap()
        {
            // Primary Key
            this.HasKey(t => t.id);

            // Properties
            this.Property(t => t.imageDir)
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("Show");
            this.Property(t => t.id).HasColumnName("id");
            this.Property(t => t.date).HasColumnName("date");
            this.Property(t => t.type_Id).HasColumnName("type_Id");
            this.Property(t => t.showRoom_Id).HasColumnName("showRoom_Id");
            this.Property(t => t.imageDir).HasColumnName("imageDir");

            // Relationships
            this.HasOptional(t => t.ShowRoom)
                .WithMany(t => t.Shows)
                .HasForeignKey(d => d.showRoom_Id);
            this.HasOptional(t => t.ShowType)
                .WithMany(t => t.Shows)
                .HasForeignKey(d => d.type_Id);

        }
    }
}
